<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('用户详情')" />
</head>
<body>
	<section class="content">
		<form class="form-horizontal" id="userDetailForm">
		    <input class="hidden" name="userId" th:value="${user.userId}">
		    <div class="box-body">
		        <div class="form-group">
		            <label  class="col-sm-3 control-label">用户名 :</label>
		            <div class="col-sm-8">
		                <input  name="username" class="form-control" readonly="readonly" required placeholder="输入用户名" th:value="${user.username}">
		            </div>
		        </div>
		        <div class="form-group">
		            <label  class="col-sm-3 control-label">邮箱 :</label>
		            <div class="col-sm-8">
		                <input name="email" class="form-control" required placeholder="输入邮箱" th:value="${user.email}">
		            </div>
		        </div>
		        <div class="form-group">
		            <label  class="col-sm-3 control-label">电话 :</label>
		
		            <div class="col-sm-8">
		                <input name="phone" class="form-control" required placeholder="输入电话" th:value="${user.phone}">
		            </div>
		        </div>
		        <div class="form-group">
		            <label  class="col-sm-3 control-label">性别 :</label>
		            <div class="col-sm-8">
		                <select name="sex" class="form-control" required>
		                    <option th:selected="${user.sex==1}" value="1">男</option>
		                    <option th:selected="${user.sex==2}" value="2">女</option>
		                </select>
		            </div>
		        </div>
		        <div class="form-group">
		            <label  class="col-sm-3 control-label">年龄 :</label>
		            <div class="col-sm-8">
		                <input name="age" class="form-control" required placeholder="输入年龄" th:value="${user.age}">
		            </div>
		        </div>
		    </div>
		</form>
	</section>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		function submitHandler() {
            if ($("#userDetailForm").validate().form()) {
                $.common.postAjax(
					ctx + "user/edit",
					$("#userDetailForm").serialize(),
					function (data) {
						if (data.code == 0) {
							parent.layer.closeAll('iframe'); // 关闭当前frame
							var topWindow = $(window.parent.document);
							var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
							var topWindow = $('.J_iframe[data-id="' + currentId + '"]', topWindow)[0];
							if (!$.common.isEmpty(topWindow) && !$.common.isEmpty(currentId)) {
								var $contentWindow = topWindow.contentWindow;
								$contentWindow.$(".layui-layer-padding").removeAttr("style");
								$contentWindow.$.table.refreshTable();
								$contentWindow.toastr.success(data.msg);
							} else {
								toastr.error(data.msg);
							}
						} else {
							toastr.error(data.msg);
						}
					}
				)
            }
    	}
	</script>
</body>
</html>